﻿<template>
	<div >
		<el-card shadow="hover" :body-style="{ paddingBottom: '0' }">
					<el-form :model="queryParams" ref="queryForm" :inline="true">
						<el-row :gutter="35">
						
			              <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6" >
			              <el-form-item>
			              <el-input v-model="queryParams.condition" clearable placeholder="堆垛机编号、设备编码、库位号"/>
			              </el-form-item>
			              </el-col>
						
                
			          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20 search-actions">
         
			          <div>
			          <el-button icon="ele-Refresh" @click="() => queryParams = {}"> 重置 </el-button>
			          <el-button type="primary" plain icon="ele-Search" @click="handleQuery" v-auth="'fmtTask:page'"> 查询 </el-button>
			          </div>
			          </el-col>
			      </el-row>
			      </el-form>
	   </el-card>
		<el-card shadow="hover" style="margin-top: 8px">
			<el-table
				:data="tableData"
				style="width: 100%"
				v-loading="loading"
				tooltip-effect="light"
				row-key="id"
				border="">
				<el-table-column type="index" label="序号" width="55" align="center" fixed="" />
				<el-table-column prop="groupNumber" label="设备编码" width="85" show-overflow-tooltip="" />
				<el-table-column prop="command" label="命令" width="70" show-overflow-tooltip="" />
				 <el-table-column prop="stage" label="库位编码" width="85" show-overflow-tooltip="" />
				 <el-table-column prop="trayID" label="托盘" width="90" show-overflow-tooltip="" />
				 <el-table-column prop="groupNumber" label="设备编码2" width="90" show-overflow-tooltip="" />
				 <el-table-column prop="stage2" label="库位编码2" width="90" show-overflow-tooltip="" />
				 <el-table-column prop="trayID2" label="托盘2" width="85" show-overflow-tooltip="" />
				 <el-table-column prop="toTagNumber" label="放货物流线" width="100" show-overflow-tooltip="" />
				

		 <el-table-column  width="150" label="叉1状态"   show-overflow-tooltip="" >
			<template #default="scope">
				       
					   <el-tag  
						 :type="scope.row.status==1 ? 'success' :'info'"
						 disable-transitions >{{ scope.row.status==0?'库位预约准备中':scope.row.status==1?'堆垛机运行中':'库位充电准备中'}}
					   </el-tag>
					 </template>
		 </el-table-column>
		  
				<el-table-column prop="appointTime" width="160" label="预约时间"   show-overflow-tooltip="" />

				<el-table-column prop="createTime" width="160" label="创建时间"   show-overflow-tooltip="" />

				<el-table-column prop="data" width="70" label="堆垛机"   show-overflow-tooltip="" />

				<el-table-column prop="errorMsg"  label="信息"   show-overflow-tooltip="" />
				
				  
				<el-table-column label="操作" width="140" align="center" fixed="right" show-overflow-tooltip="" >
					<template #default="scope">
						
						<el-button icon="ele-Close" size="small" text="" type="primary" @click="deleteControl(scope.row)" v-auth="'fmtTask:delete'"> 删除 </el-button>
						
					</template>
				</el-table-column>
			</el-table>
			
			
		</el-card>
	</div>
</template>

<script lang="ts" setup>
	import { ref } from "vue";
	import { ElMessageBox, ElMessage } from "element-plus";
	import { auth } from '/@/utils/authFunction';
	//import { formatDate } from '/@/utils/formatTime';

	
	import { GetAppointJob,RemoveAppointJob } from '/@/api/main/grpcServer';


		
		const loading = ref(false);
		const tableData = ref<any>([]);
		const queryParams = ref<any>(
		{	
			
		});
	
	const tableParams = ref({
	page: 1,
	pageSize: 10,
	total: 0,
	});

	

	// 查询操作
	const handleQuery = async () => {
	loading.value = true;
	let para={
		condition:'0',
			
		};
	if(queryParams.value){
		
		para=JSON.parse(JSON.stringify(queryParams.value));
		if(!queryParams.value.condition){
			para.condition='0';
		}
		
	}
	
	var res = await GetAppointJob();
	let datas:any[]=[];

	datas=res.data.result;


	if(datas && para.condition!='0'){
		datas=datas.filter((x)=>{
			return x.groupNumber==para.condition  || x.groupNumber2==para.condition || x.stage==para.condition || x.stage2==para.condition || x.data==para.condition;
		})
	}
	tableData.value = datas;
	tableParams.value.total = res.data.result?.length;
	loading.value = false;
};





 




const deleteControl=async(row:any)=>{

ElMessageBox.confirm(
'是否删除充放电预约任务?',
'警告',
{
  confirmButtonText: '确定',
  cancelButtonText: '取消',
  type: 'warning',
}
)
.then(async() => {


 await RemoveAppointJob(row);
  ElMessage({
	type: 'success',
	message: '操作完成',
  })
})
};




handleQuery();
</script>


